

import os 

path = r'F:\desktop\23年毕设\模型\calc_mAP\val_images_dir'

def main():

    ls = os.listdir(path)
    with open("JPEGImages_set", "a+") as f:
        for i in ls:
            f.write(i[:i.find(".")] + '\n')

main()